package com.momomian.common.exception;

/**
 * @author momomian
 * @date 2021/12/28
 * 用于校验抛出异常
 */
public class CheckExceptionUtil {


    public static ThrowExceptionFunction isTrue(boolean b) {
        return (resCodeEnum) -> {
            if (b) {
                throw new BusinessException(resCodeEnum.getCode(), resCodeEnum.getDescription());
            }
        };
    }

    public static ThrowExceptionMsgFunction isTrueThenMsg(boolean b) {
        return (code, msg) -> {
            if (b) {
                throw new BusinessException(code, msg);
            }
        };
    }
}
